package edu.hrbu.service.impl;

import edu.hrbu.mapper.MenuMapper;
import edu.hrbu.pojo.Menu;
import edu.hrbu.service.MenuService;
import edu.hrbu.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author 徐登宇
 * @date 2022-10-26 19:06
 */
public class MenuServiceImpl implements MenuService {

    @Override
    public List<Menu> getMenuList(Integer roleId, Integer parentId) {
        SqlSession sqlSession = SqlSessionUtil.getSqlSession();
        MenuMapper mapper = sqlSession.getMapper(MenuMapper.class);
        List<Menu> menuList = mapper.getMenuList(roleId, parentId);
        sqlSession.close();
        return menuList;
    }

    @Override
    public List<Menu> getAllMenuByRoleId(int roleId) {
        SqlSession sqlSession = SqlSessionUtil.getSqlSession();
        MenuMapper mapper = sqlSession.getMapper(MenuMapper.class);
        List<Menu> menuList = mapper.getAllMenu(roleId);
        sqlSession.close();
        return menuList;
    }
}
